package com.ls.security;

import java.io.DataOutputStream;
import java.io.File;
import java.net.URL;
import java.util.Map;
import java.util.Random;

import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Test;

import com.google.common.collect.Maps;
import com.google.gson.Gson;

public class RandomUtils {

//	@Test
	public void generateRandom(){
		
		for(int i = 0 ;i<10;i++){
			DataOutputStream out ;
			System.out.println(RandomStringUtils.random(10,false,true));
		}
	}
	
//	@Test
	public void generateRandombasicNum(){
		for(int i = 0 ;i<10;i++){
			System.out.println(RandomStringUtils.random(10,0,0,true,true,null,new Random(i)));
		}
		Gson gson = new Gson();
		Pair<String,String> pair;
	}
//	@Test
	public void generateMap(){
		Map<String,String> a = Maps.newHashMap();
		a.put("c", "cc");
		a.put("c2", "cc2");
		a.put("c3", "cc3");
		System.out.println(a);
	}
	
//	@Test
	public void testResource(){
		URL url = Thread.currentThread().getContextClassLoader().getResource("log4j.properties");
		URL url2 = Thread.currentThread().getContextClassLoader().getResource("cache.xml");
		if(url!=null){
			System.out.println(new File(url.getFile()));
			System.out.println(url2);
		}
		
		System.out.println(String.format("tims is : %l ",System.currentTimeMillis()));
	}
	
	@Test
	public void testDiv(){
		int a=1;
		int b=3;
		float c = (float) a/ b;
		System.out.print(c);//输出：1.3333334
	}
}
